function ProductCommentAssistant(argFromPusher) {
	this.product = argFromPusher.product;
	this.start = argFromPusher.start;
	if(! this.start) this.start = 0;
}

ProductCommentAssistant.prototype = {
	product: null,
	count: 10,
	start: 0,
	total: 0,
	setup: function() {
		Ares.setupSceneAssistant(this);
		this.$.header.setTitle("Comments of " + this.product.name);
		this.getComments();
	},
	cleanup: function() {
		Ares.cleanupSceneAssistant(this);
	},
	getComments: function() {
		var args = {
			nid: this.product.nid,
			count: this.count,
			start: this.start
		}
		drupalService('comment.loadNodeComments', args, this, function(data) {
			data.each(function(d){
				d.timeStr = new Date(parseInt(d.timestamp)*1000).toString().substring(4,24);
				if(d.name == "") d.name = "anonymous";
			});
			this.$.commentList.setItems(data);
		}.bind(this));
		drupalService('comment.countAll', {nid: this.product.nid}, this, function(data) {
			this.total = data;
		}.bind(this));
	},
	button1Tap: function(inSender, event) {
		if(this.start == 0)
			myAlert(this, "You are already in first page.")
		else{
			var prevStart = this.start - this.count;
			if(prevStart < 0) prevStart = 0;
			Mojo.Controller.stageController.popScene();
			Mojo.Controller.stageController.pushScene("productComment",{product: this.product, start: prevStart});
		}
		
	},
	button2Tap: function(inSender, event) {
		var nextStart = this.start + this.count;
		if(nextStart > this.total-1)
			myAlert(this, "You are already in last page.")
		else{
			Mojo.Controller.stageController.popScene();
			Mojo.Controller.stageController.pushScene("productComment",{product: this.product, start: nextStart});
		}
	}
};